package com.lagou.dubboconsumer;

import com.lagou.dubboapi.HelloService;
import org.apache.dubbo.config.annotation.Reference;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.io.IOException;

/**
 * @author zhangxuyuan
 * @version 1.0
 * @date 2020/12/18
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = ConsumerApp.class)
public class ConsumerTest {

    @Reference
    HelloService helloService;

    @Test
    public void test01() throws IOException {
        Thread thread1 = new Thread(new Runnable() {
            @Override public void run() {
                for (int i = 0; i < 1000; i++) {
                    helloService.sayHelloA("a");
                }
            }
        });

        Thread thread2 = new Thread(new Runnable() {
            @Override public void run() {
                for (int i = 0; i < 1000; i++) {
                    helloService.sayHelloB("b");
                }
            }
        });

        Thread thread3 = new Thread(new Runnable() {
            @Override public void run() {
                for (int i = 0; i < 1000; i++) {
                    helloService.sayHelloC("c");
                }
            }
        });
        thread1.start();thread2.start();thread3.start();
        System.in.read();
    }
}
